<script language="JavaScript" type="text/javascript">
/*<![CDATA[*/
	$(function(){
		$("#chkToggle").click(function(){
			var elements = $("form :checkbox");
			if(this.checked){
				elements.each(function(element){
					this.checked = true;
					document.forms[0].hndBoxChecked.value ++;
				});
			}else{
				elements.each(function(element){
					this.checked = false;
				});
				document.forms[0].hndBoxChecked.value = 0;
			}
		});

		$("#lnkAdd").click(function(){
			var form = document.adminForm;
			//form.action = '<?php echo DOMAIN?>/acl_rules/add/<?php echo $id ;?>';
			form.submit();
		});
		
		$("#lnkBack").click(function(){
			window.location = 'index.php?progid=22';
		});

		$("#lnkDelete").click(function(){
			var form = document.adminForm;
			if(form.hndBoxChecked.value==0){
				alert('Bạn phải chọn một mục để xóa');
			}else if(confirm('Bạn có chắc muốn xóa mục này không?')){
				form.action = '';
				form.submit();
			}
		});

	});

	function isChecked(checkObject){
		if (checkObject.checked == true){
			document.adminForm.hndBoxChecked.value ++;
		}else {
			document.adminForm.hndBoxChecked.value --;
		}
	}

	function getSelectedID(){
		var IDs = "";
		$('input[name=chkID]:checkbox').each(function(){
			if(this.checked){
				if(IDs.isEmpty()){
					IDs = this.value;
				}else{
					IDs += "|" + this.value;
				}
			}
		});
		return IDs;
	}
/*]]>*/
</script>

<div id="content-box">
	<div class="border">
		<div class="padding">
			<div id="toolbar-box">
				<div class="t"><div class="t"><div class="t"></div></div></div>
				<div class="m">
				<div class="toolbar" id="toolbar">
				<table class="toolbar" summary="">
				<tr>
					<td class="button" id="toolbar-new">
						<a href="javascript:;//Quay lại" class="toolbar" id="lnkBack">
							<span class="icon-32-back" title="Quay lại"></span>
							Quay lại
						</a>
					</td>
					<td class="button" id="toolbar-new">
						<a href="javascript:;//Thêm" class="toolbar" id="lnkAdd">
							<span class="icon-32-new" title="Thêm"></span>
							Thêm
						</a>
					</td>
					<td class="button" id="toolbar-delete">
						<a href="javascript:;//Xóa" class="toolbar" id="lnkDelete">
							<span class="icon-32-delete" title="Xóa"></span>
							Xóa
						</a>
					</td>
				</tr>
				</table>
				</div>
            
				<div class="header icon-48-langmanager">Quản lý Quyền truy cập  <?php ///echo $role_name;?></div>
				<div class="clr"></div>
			</div>
			<div class="b"><div class="b"><div class="b"></div></div></div>
  		</div>
   		<div class="clr"></div>
		<div id="element-box">
			<div class="t"><div class="t"><div class="t"></div></div></div>
			<div class="m">
			<form action="<?php echo DOMAIN?>/acl_rules/add" method="post" name="adminForm" id="adminForm">
			<fieldset class="adminform">
				<legend>Chi tiết quyền truy cập</legend>
				<table class="admintable" cellspacing="1">
				<tr>
					<td class="key">
						<label for="cbResource">Tài nguyên</label>
					</td>
					<td>
						
							 <?php  echo $form->select('Resource.resource_id',$list,null,array('empty'=>'Chọn một tài nguyên')); ?>
					
						<label for="cbResource" class="error"><br /></label>
					</td>
				</tr>
				<tr>
					<td class="key">Quyền</td>
					<td>
						<select id="chkPrivileges" name="chkPrivileges[]" size="6"  multiple="multiple" style="width:150">
							<!--<option value="view">- Xem -</option>-->
							<option value="1">- Thêm -</option>
							<option value="2">- Sửa -</option>
							<option value="3">- Xóa -</option>
						</select>
					</td>
                   	<?php echo $form->input('Check.id',array( 'label' => '','id'=>'txtOrder','value'=>$id,'size'=>'40','type'=>'hidden'));?>
				</tr>
				</table>
                
		
				<input type="reset" name="btnReset" id="btnReset" value="Reset" style="display:none;">
			</fieldset>
			<fieldset class="adminform">
				<legend>Danh sách Quyền truy cập</legend>
				<table class="adminlist" cellpadding="1" summary="">
				<thead>
					<tr>
						<th width="2%" class="title">#</th>
						<th width="3%" class="title">
							<input type="checkbox" name="chkToggle" value="" id="chkToggle" />
						</th>
						<th  class="title" nowrap="nowrap">
							Tên controler
						</th>
						<th  class="title" nowrap="nowrap">
							Quyền
						</th>
						<th width="5%" class="title" nowrap="nowrap">
							ID
						</th>
					</tr>
				</thead>
				<tfoot>
					<tr>
						<td colspan="10">
							<del class="container"><div class="pagination"><div class="limit"><?php  //view_page('index.php?progid=23&role_id='.$role_id); ?></div><div class="limit"></div></div></del>
						</td>
					</tr>
				</tfoot>
				<tbody>
					<?php  foreach ($ListAclRule as $key=>$nameController){ $i=$key+1; ?>
					<tr class="row0">
						<td align="center"><?php  echo $i?></td>
						<td align="center">
							<input type="checkbox" id="cb<?php  echo $nameController['AclRule']['id']?>" name="chkId[]" value="<?php  echo $nameController['AclRule']['id'] ?>" onclick="isChecked(this.checked);" />
						</td>
						<td>
							<?php  echo $nameController['Resource']['comment']?>
						</td>
						<td >
							<?php  if( $nameController['AclRule']['add']==1){
										 echo 'add |';}
									 if($nameController['AclRule']['eidt']==2){
										echo ' Edit |';
									}if($nameController['AclRule']['delete']==3){
										echo ' Delete';
									}
							?>
						</td>
						<td >
							<?php  echo $nameController['AclRule']['id']?>
						</td>
                        
					</tr>
					<?php }?>
				</tbody>
				</table>
			</fieldset>
		</form>
			<div class="clr"></div>
			</div>
			<div class="b"><div class="b"><div class="b"></div></div></div>
   		</div>
		<noscript>Warning! JavaScript must be enabled for proper operation of the Administrator back-end.</noscript>
		<div class="clr"></div>
	</div>
	<div class="clr"></div>
	</div>
</div>

